<?php

/**
 * 商品类
 */
class ProductController extends \BaseController {

    /**
     *获取所有商品的概要信息
     * @return Response
     * 返回json格式:
     * ```
     *   [
     *     {
     *       "id":number
     *       "label":string
     *       "productList":
     *       [
     *         {
     *           "id": number,
     *           "name": string,
     *           "image": string,
     *           "price": number
     *         }
     *       ]
     *     }
     *   ]
     * ```
     */
    public function index()
    {
        $resp = Product::getFormatProducts();
        return Response::json($resp);
    }


    /**
     * 获取特定商品详细信息
     * 返回json格式:
     * ```
     * {
     *   "baseInfo":
     *   {
     *     "class_id": number,
     *     "id": number,
     *     "name": string,
     *     "image": string,
     *     "price": number,
     *     "description": string,
     *     "amount": number
     *   }
     * }
     * ```
     * @param  int  $id
     * @return Response
     */
    public function show($id)
    {
	      return Response::json([
            "baseInfo" => Product::find($id)->toArray()
        ]);
    }




    /**
     * 更新特定商品的某些信息(如收藏次数，作为保留功能)
     *
     * @param  int  $id
     * @return Response
     */
    public function update($id)
    {

    }

}
